import { PartialType } from '@nestjs/mapped-types';
import { CreateUserDto } from './create-user.dto';
import { IsArray, IsInt, IsNotEmpty, IsOptional, IsString, ValidateIf } from 'class-validator';
import { Type } from 'class-transformer';
import { CreateRoleDto } from '@/examples/role/dto/create-role.dto';

export class UpdateUserDto extends PartialType(CreateUserDto) {
    @IsInt()
    @IsOptional()
    id?: number;

    @IsString()
    @ValidateIf(o => !o.id)
    name: string;

    @IsArray()
    @Type(() => CreateRoleDto)
    @IsOptional()
    roles?: any[];
}
